package com.xyhuo.leetcode.january;

/**
 * 只出现一次的数字
 * https://leetcode.cn/problems/single-number/
 *
 * @time 2024/1/17
 */
public class SingleNumber {

    public int singleNumber(int[] nums) {
        int ans = nums[0];
        if (nums.length > 1) {
            for (int i = 1; i < nums.length; i++) {
                ans = ans ^ nums[i];
            }
        }
        return ans;
    }
}
